package com.conan.array.exer1;/** * @version 加油！！！ * @Description     数组缩容 {1,2,3,4,5,6,7},删除数组中索引为4的元素 * @Author 谷藤新一GYC * @Date 2023/7/30-10:28 */public class ArrayTest10 {    public static void main(String[] args) {        int deleteIndex = 4;        int[] arr = new int[]{1,2,3,4,5,6,7};        //方式一，不新建数组//        for(int i = deleteIndex;i < arr.length-1;i++){//            arr[i] = arr[i+1];//        }//        arr[arr.length-1] = 0;        //方式二新建数组        int [] newArr = new int[arr.length-1];        for(int i = 0;i < deleteIndex;i++){            newArr[i] = arr[i];        }        for(int i = deleteIndex;i < arr.length-1;i++){            newArr[i] = arr[i+1];        }        arr = newArr;        for (int i = 0; i < arr.length; i++) {            System.out.print(arr[i]+"\t");        }    }}   